package com.pearl.maskencrypt.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pearl.maskencrypt.demo.entity.UserEntity;
import com.pearl.maskencrypt.demo.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 自动代码生成
 * @since 2024-02-06
 */
@Slf4j
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping("/save")
    public Object save(){
        UserEntity user=new UserEntity();
        user.setUserName("测试");
        user.setPassword("123456");
        user.setLoginName("QBCD");
        user.setIdNumber("430821195612250202");
        user.setGender(1);
        user.setEmail("weew@qq.com");
        userService.save(user);
        return  "操作成功";
    }

    @GetMapping("/list")
    public Object list() {
        return userService.list();
    }

    @GetMapping("/listByIdNumber")
    public Object listByIdNumber() {
        LambdaQueryWrapper<UserEntity> queryWrapper = Wrappers.lambdaQuery();
        return userService.list(queryWrapper.eq(UserEntity::getIdNumber,"430821195612250202"));
    }

    @GetMapping("/listByPwd")
    public Object listByPwd() {
        LambdaQueryWrapper<UserEntity> queryWrapper = Wrappers.lambdaQuery();
        return userService.list(queryWrapper.eq(UserEntity::getPassword,"123456"));
    }

    @GetMapping("/listByIdNumberLike")
    public Object listByIdNumberLike() {
        //
        //
        //
        //
        //
        LambdaQueryWrapper<UserEntity> queryWrapper = Wrappers.lambdaQuery();
        return userService.list(queryWrapper.like(UserEntity::getIdNumber,"43082"));
    }
}
